<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>LibTools: H:/project/LibTools/src/log/SafeLog.cpp 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">LibTools
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.16 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','搜索');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_2241064965c8d9ca993f08b926076f7d.html">log</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">SafeLog.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_safe_log_8cpp.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_safe_log_8h.html">SafeLog.h</a>&quot;</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#include &quot;../thread/Mutex.h&quot;</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &quot;../time/Time.h&quot;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;../tools/ShareApi.h&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;../file/FileTools.h&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &lt;stdlib.h&gt;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160; </div>
<div class="line"><a name="l00009"></a><span class="lineno"><a class="line" href="_safe_log_8cpp.html#a660395cdc8ba7aca573aed6c676faae8">    9</a></span>&#160;<a class="code" href="_safe_log_8cpp.html#a660395cdc8ba7aca573aed6c676faae8">USE_LIBTOOLS</a>;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160; </div>
<div class="line"><a name="l00011"></a><span class="lineno"><a class="line" href="_safe_log_8cpp.html#a44eb26d33eb6c5e235c6cbfa377f60ae">   11</a></span>&#160;<span class="preprocessor">#define ONE_DAY 86400 // 一天的秒数</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160; </div>
<div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a8eb7b4e7971918a139c09db5a7926767">   13</a></span>&#160;<a class="code" href="class_c_safe_logs.html#a8eb7b4e7971918a139c09db5a7926767">CSafeLogs::CSafeLogs</a>()</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;{</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    <a class="code" href="class_c_safe_logs.html#acfec8eab5ce3695c7f3c111bc42b9ddf">_nFileMaxSize</a> = <a class="code" href="_safe_log_8h.html#af5f39b12ec7524d513a48e9b662a445a">DEFAULT_LOG_SIZE</a>;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;    <a class="code" href="class_c_safe_logs.html#a3dd941c690e7a627b27eca4c62f7d91a">_nFlushTime</a> = <a class="code" href="_safe_log_8h.html#acf3ddfcd82496629d7ab869a57f2fedd">DEFAULT_FLUSH_TIME</a>;</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;    <a class="code" href="class_c_safe_logs.html#a4b0aebbbd5501c2d7924fcf90f169e9c">_nLogLevel</a> = <a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9abb2c17c44c343a8367060db4175f39ea">LOG_NORMAL</a>;</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;    <a class="code" href="class_c_safe_logs.html#a792e2fc28b9c58bf53c98163e055a5dd">_isWriteConsole</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    <a class="code" href="class_c_safe_logs.html#aef956466255d247b0353aa78b683cd68">_tLastWrite</a> = 0;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    <a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference() = <a class="code" href="tools_8h.html#a5fc7b9645f751ccc053f6f59ab0d8924">TEXT</a>(<span class="stringliteral">&quot;./logs/&quot;</span>);</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;}</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a9f29f7c86f06e7dac75dccd844c7348b">   23</a></span>&#160;<a class="code" href="class_c_safe_logs.html#a8eb7b4e7971918a139c09db5a7926767">CSafeLogs::CSafeLogs</a>(<span class="keyword">const</span> <a class="code" href="tools_8h.html#a65c91f8d7af3c67b8a21e089fdddd0fe">TCHAR</a>* szLogPath, <a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9">LogLevel</a> nLogLevel <span class="comment">/* = LOG_NORMAL */</span>,</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <a class="code" href="tools_8h.html#a57be03562867144161c1bfee95ca8f7c">UINT64</a> nFileMaxSize <span class="comment">/* = DEFAULT_LOG_SIZE */</span>, <a class="code" href="tools_8h.html#a36cb3b01d81ffd844bbbfb54003e06ec">UINT</a> nfTime <span class="comment">/* = DEFAULT_FLUSH_TIME */</span>)</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;{</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;    <a class="code" href="class_c_safe_logs.html#acfec8eab5ce3695c7f3c111bc42b9ddf">_nFileMaxSize</a> = nFileMaxSize;</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <a class="code" href="class_c_safe_logs.html#a3dd941c690e7a627b27eca4c62f7d91a">_nFlushTime</a> = nfTime;</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;    <a class="code" href="class_c_safe_logs.html#aef956466255d247b0353aa78b683cd68">_tLastWrite</a> = 0;</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    <a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference() = szLogPath;</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;    <a class="code" href="class_c_safe_logs.html#a4b0aebbbd5501c2d7924fcf90f169e9c">_nLogLevel</a> = nLogLevel;</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    <a class="code" href="class_c_safe_logs.html#a792e2fc28b9c58bf53c98163e055a5dd">_isWriteConsole</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <span class="comment">// 添加后缀符号</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    <span class="keywordflow">if</span> (*(<a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference().end() - 1) != <a class="code" href="tools_8h.html#a5fc7b9645f751ccc053f6f59ab0d8924">TEXT</a>(<span class="charliteral">&#39;/&#39;</span>) &amp;&amp; *(<a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference().end() - 1) != <a class="code" href="tools_8h.html#a5fc7b9645f751ccc053f6f59ab0d8924">TEXT</a>(<span class="charliteral">&#39;\\&#39;</span>)){</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;        <a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference().push_back(<a class="code" href="tools_8h.html#a5fc7b9645f751ccc053f6f59ab0d8924">TEXT</a>(<span class="charliteral">&#39;/&#39;</span>));</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    }</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;}</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160; </div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a64b9b0012769472f36a4f89c5bf141ef">   38</a></span>&#160;<a class="code" href="class_c_safe_logs.html#a64b9b0012769472f36a4f89c5bf141ef">CSafeLogs::~CSafeLogs</a>()</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;{</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160; </div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;}</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a972c8fa984c8698181dcefbb2ac492fb">   43</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_c_safe_logs.html#a972c8fa984c8698181dcefbb2ac492fb">CSafeLogs::SetLogPath</a>(<span class="keyword">const</span> <a class="code" href="tools_8h.html#a65c91f8d7af3c67b8a21e089fdddd0fe">TCHAR</a>* szLogPath)</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;{</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <a class="code" href="class_c_lock_gurad.html">CLockGurad</a> lock(&amp;<a class="code" href="class_c_safe_logs.html#abed76fa949bfb689a91dd7f86eb68634">_fileMutex</a>);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference() = szLogPath;</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="keywordflow">if</span> (*(<a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference().end() - 1) != <span class="charliteral">&#39;/&#39;</span> &amp;&amp; *(<a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference().end() - 1) != <span class="charliteral">&#39;\\&#39;</span>)</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    {</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        <a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference().push_back(<a class="code" href="tools_8h.html#a5fc7b9645f751ccc053f6f59ab0d8924">TEXT</a>(<span class="charliteral">&#39;/&#39;</span>));</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    }</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;}</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a41d1dba7d735f5340dca726f889f5090">   53</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_c_safe_logs.html#a41d1dba7d735f5340dca726f889f5090">CSafeLogs::SetLogLevel</a>(<a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9">LogLevel</a> nLogLevel)</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;{</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    <a class="code" href="class_c_lock_gurad.html">CLockGurad</a> lock(&amp;<a class="code" href="class_c_safe_logs.html#abed76fa949bfb689a91dd7f86eb68634">_fileMutex</a>);</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <a class="code" href="class_c_safe_logs.html#a4b0aebbbd5501c2d7924fcf90f169e9c">_nLogLevel</a> = nLogLevel;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;}</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160; </div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a2a129a4fcd8c51a5c6830098943cf7bb">   59</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_c_safe_logs.html#a2a129a4fcd8c51a5c6830098943cf7bb">CSafeLogs::SetWriteConsole</a>(<span class="keywordtype">bool</span> isWriteConsole)</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;{</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    <a class="code" href="class_c_lock_gurad.html">CLockGurad</a> lock(&amp;<a class="code" href="class_c_safe_logs.html#abed76fa949bfb689a91dd7f86eb68634">_fileMutex</a>);</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    <a class="code" href="class_c_safe_logs.html#a792e2fc28b9c58bf53c98163e055a5dd">_isWriteConsole</a> = isWriteConsole;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;}</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160; </div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a79ac12b58225066b1533f190a579e64b">   65</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_c_safe_logs.html#a79ac12b58225066b1533f190a579e64b">CSafeLogs::SetLogFileSize</a>(<a class="code" href="tools_8h.html#a57be03562867144161c1bfee95ca8f7c">UINT64</a> nFileMaxSize)</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;{</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <a class="code" href="class_c_lock_gurad.html">CLockGurad</a> lock(&amp;<a class="code" href="class_c_safe_logs.html#abed76fa949bfb689a91dd7f86eb68634">_fileMutex</a>);</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <a class="code" href="class_c_safe_logs.html#acfec8eab5ce3695c7f3c111bc42b9ddf">_nFileMaxSize</a> = nFileMaxSize;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;}</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a94a6c995167ac24ca71660e48fd0ce32">   71</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_c_safe_logs.html#a94a6c995167ac24ca71660e48fd0ce32">CSafeLogs::SetSwitchFile</a>(<a class="code" href="tools_8h.html#a36cb3b01d81ffd844bbbfb54003e06ec">UINT</a> nfTime)</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;{</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <a class="code" href="class_c_lock_gurad.html">CLockGurad</a> lock(&amp;<a class="code" href="class_c_safe_logs.html#abed76fa949bfb689a91dd7f86eb68634">_fileMutex</a>);</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    <a class="code" href="class_c_safe_logs.html#a3dd941c690e7a627b27eca4c62f7d91a">_nFlushTime</a> = nfTime;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;}</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160; </div>
<div class="line"><a name="l00077"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a1b5d1015ebfbb6596c5a889605679c57">   77</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_safe_logs.html#a67a16f7ebc22906bf159e3a8f88c5124">CSafeLogs::WriteLog</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* szLog, <a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9">LogLevel</a> nLogLevel)</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;{</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_safe_logs.html#a67a16f7ebc22906bf159e3a8f88c5124">WriteLog</a>(szLog, 0, nLogLevel, <span class="keyword">true</span>, <span class="keyword">true</span>);</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;}</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160; </div>
<div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a67a16f7ebc22906bf159e3a8f88c5124">   82</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_safe_logs.html#a67a16f7ebc22906bf159e3a8f88c5124">CSafeLogs::WriteLog</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* szLog, <a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> size, <a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9">LogLevel</a> nLogLevel)</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;{</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_safe_logs.html#a67a16f7ebc22906bf159e3a8f88c5124">WriteLog</a>(szLog, size, nLogLevel, <span class="keyword">true</span>, <span class="keyword">true</span>);</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;}</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160; </div>
<div class="line"><a name="l00087"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a7ecaa2fd3c7a077e8f5f625e07de1fee">   87</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_c_safe_logs.html#a7ecaa2fd3c7a077e8f5f625e07de1fee">CSafeLogs::FlushLog</a>()</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;{</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    <span class="comment">// 换行</span></div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="class_c_safe_logs.html#a792e2fc28b9c58bf53c98163e055a5dd">_isWriteConsole</a>) std::cout &lt;&lt; std::endl;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">_file</a>.<a class="code" href="class_c_file.html#a68f6596c56190afd38fbe236ade81266">Write</a>(<span class="stringliteral">&quot;\r\n&quot;</span>, 2) == -1 ? false : <span class="keyword">true</span>;</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;}</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160; </div>
<div class="line"><a name="l00094"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a353b09fdf1a3a8f57d41c0cd94825765">   94</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_safe_logs.html#a353b09fdf1a3a8f57d41c0cd94825765">CSafeLogs::WriteLogHead</a>(<a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9">LogLevel</a> nLogLevel)</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;{</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    std::string str;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    str = <a class="code" href="tools_8h.html#acc6d8511211e23ff33647d261f6f8b59">STD_MOVE</a>(<a class="code" href="_string_tools_8cpp.html#accff640a08f04f7443e0da4eb25a4cf0">format_s</a>(100, <span class="stringliteral">&quot;[%s(%s)] &quot;</span>, <a class="code" href="class_c_time_tools.html#a86ff8e1d027ce0f6bc7611c430672f73">CTimeTools::GetTimeStr</a>().c_str(), <a class="code" href="logdef_8h.html#adc056e8970ce3dbab05a500d9f2b17f8">GetLogLevelStr</a>(nLogLevel)));</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="class_c_safe_logs.html#a792e2fc28b9c58bf53c98163e055a5dd">_isWriteConsole</a>) std::cout &lt;&lt; str;</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    <a class="code" href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">_file</a>.<a class="code" href="class_c_file.html#a68f6596c56190afd38fbe236ade81266">Write</a>(str.data(), str.size());</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160; </div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    <span class="keywordflow">return</span> str.size();</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;}</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160; </div>
<div class="line"><a name="l00104"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#ab6c462e9c6af249f86949eeb83b4d7db">  104</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_safe_logs.html#a67a16f7ebc22906bf159e3a8f88c5124">CSafeLogs::WriteLog</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* szLog, <a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> size, <a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9">LogLevel</a> nLogLevel, <span class="keywordtype">bool</span> bHead, <span class="keywordtype">bool</span> bFlush)</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;{   </div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <a class="code" href="class_c_lock_gurad.html">CLockGurad</a> lock(&amp;<a class="code" href="class_c_safe_logs.html#abed76fa949bfb689a91dd7f86eb68634">_fileMutex</a>);</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_safe_logs.html#a7269da8c406a066045bbda712700c568">_WriteLog</a>(szLog, size, nLogLevel, bHead, bFlush);</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;}</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160; </div>
<div class="line"><a name="l00110"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#a7269da8c406a066045bbda712700c568">  110</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_safe_logs.html#a7269da8c406a066045bbda712700c568">CSafeLogs::_WriteLog</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* szLog, <a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> size, <a class="code" href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9">LogLevel</a> nLogLevel, <span class="keywordtype">bool</span> bHead, <span class="keywordtype">bool</span> bFlush)</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;{</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;    <span class="keywordflow">if</span> (size == 0 &amp;&amp; szLog != <a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>) size = strlen(szLog);</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordflow">if</span> (nLogLevel &lt; <a class="code" href="class_c_safe_logs.html#a4b0aebbbd5501c2d7924fcf90f169e9c">_nLogLevel</a>) <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160; </div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    time_t curTime = time(<a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>);</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160; </div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    <span class="comment">// 达到切换条件的则切换日志（跨天、长度限制、默认切换时间）</span></div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="keywordflow">if</span> ((labs((<span class="keywordtype">long</span>)(curTime - <a class="code" href="class_c_safe_logs.html#aef956466255d247b0353aa78b683cd68">_tLastWrite</a>)) &gt;= (<span class="keywordtype">long</span>)<a class="code" href="class_c_safe_logs.html#a3dd941c690e7a627b27eca4c62f7d91a">_nFlushTime</a>) ||</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        (<a class="code" href="class_c_time_tools.html#ab9cac1735bbfdc48f8c70c3acb7bd4ba">CTimeTools::GetDateValue</a>(&amp;curTime) - <a class="code" href="class_c_time_tools.html#ab9cac1735bbfdc48f8c70c3acb7bd4ba">CTimeTools::GetDateValue</a>(&amp;<a class="code" href="class_c_safe_logs.html#aef956466255d247b0353aa78b683cd68">_tLastWrite</a>) &gt; 0) ||</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;        <a class="code" href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">_file</a>.<a class="code" href="class_c_file.html#a0e1ef74f4c6c2e04b9577d208c2499e9">GetFileLength</a>() &gt;= (<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a>)<a class="code" href="class_c_safe_logs.html#acfec8eab5ce3695c7f3c111bc42b9ddf">_nFileMaxSize</a> ||</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;        <a class="code" href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">_file</a>.<a class="code" href="class_c_file.html#a50e268d58e7d90f6ba8448ea8e154211">IsOpen</a>() == false</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        )</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    {</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;        <a class="code" href="class_c_safe_logs.html#aef956466255d247b0353aa78b683cd68">_tLastWrite</a> = curTime;</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;        <a class="code" href="class_c_safe_logs.html#aeb6f84401d06477a6dc85cb44f029fc7">SwitchLogFile</a>();</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;    }</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160; </div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    <span class="comment">// 写入头数据</span></div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> totleSize = 0;</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    <span class="keywordflow">if</span> (bHead) {</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;        totleSize += <a class="code" href="class_c_safe_logs.html#a353b09fdf1a3a8f57d41c0cd94825765">WriteLogHead</a>(nLogLevel);</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    }</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160; </div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <span class="comment">// 写入日志体</span></div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="class_c_safe_logs.html#a792e2fc28b9c58bf53c98163e055a5dd">_isWriteConsole</a> &amp;&amp; szLog) std::cout &lt;&lt; szLog;</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    totleSize += <a class="code" href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">_file</a>.<a class="code" href="class_c_file.html#a68f6596c56190afd38fbe236ade81266">Write</a>(szLog, size);</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160; </div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    <span class="comment">// 是否立即写入文件并换行</span></div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    <span class="keywordflow">if</span> (bFlush) {</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;        <a class="code" href="class_c_safe_logs.html#a7ecaa2fd3c7a077e8f5f625e07de1fee">FlushLog</a>();</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    }</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160; </div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="keywordflow">return</span> totleSize;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;}</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160; </div>
<div class="line"><a name="l00146"></a><span class="lineno"><a class="line" href="class_c_safe_logs.html#aeb6f84401d06477a6dc85cb44f029fc7">  146</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_c_safe_logs.html#aeb6f84401d06477a6dc85cb44f029fc7">CSafeLogs::SwitchLogFile</a>()</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;{</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="comment">// 按天切换目录</span></div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;    <a class="code" href="class_c_safe_logs.html#a56df89a4b10c88b3f510ce1353e3ff76">_strCurPath</a>.GetReference() = <a class="code" href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">_strLogPath</a>.GetReference() + <a class="code" href="_string_tools_8h.html#a0a60694576e1be5888918efa92f551d2">TO_TSTRING</a>(<a class="code" href="tools_8h.html#acc6d8511211e23ff33647d261f6f8b59">STD_MOVE</a>(<a class="code" href="class_c_time_tools.html#ade52c34673cca32faab3ac984e1b40c5">CTimeTools::GetDateStr</a>()));</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    <a class="code" href="class_c_safe_logs.html#a56df89a4b10c88b3f510ce1353e3ff76">_strCurPath</a>.GetReference() += <a class="code" href="tools_8h.html#a5fc7b9645f751ccc053f6f59ab0d8924">TEXT</a>(<span class="stringliteral">&quot;/&quot;</span>);</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;    <span class="comment">// 没有此目录则创建</span></div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="namespace_share_api.html#af5477174100c9b0c5fa9b8a1787c09af">ShareApi::FilePathExists</a>(<a class="code" href="class_c_safe_logs.html#a56df89a4b10c88b3f510ce1353e3ff76">_strCurPath</a>.GetReference().c_str())){</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;        <a class="code" href="_file_tools_8cpp.html#ac466c2c83e8a6b7daf322c2ad4590e0f">LibTools::CreateMultiDir</a>(<a class="code" href="class_c_safe_logs.html#a56df89a4b10c88b3f510ce1353e3ff76">_strCurPath</a>.GetReference().c_str());</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;    }</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160; </div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    <span class="comment">// 当前路径+时间+进程号+线程号</span></div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <a class="code" href="class_c_safe_logs.html#a08dde93476a99eabe315b0c618f05ecc">_strFileName</a>.GetReference() = <a class="code" href="tools_8h.html#acc6d8511211e23ff33647d261f6f8b59">STD_MOVE</a>(<a class="code" href="_string_tools_8cpp.html#a68e59768ff7f1f1fe4dca5ccaa26de28">format</a>(<a class="code" href="tools_8h.html#a5fc7b9645f751ccc053f6f59ab0d8924">TEXT</a>(<span class="stringliteral">&quot;%s%s-%lu-%lu.log&quot;</span>), <a class="code" href="class_c_safe_logs.html#a56df89a4b10c88b3f510ce1353e3ff76">_strCurPath</a>.GetReference().c_str(), </div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;        <a class="code" href="_string_tools_8h.html#a0a60694576e1be5888918efa92f551d2">TO_TSTRING</a>(<a class="code" href="tools_8h.html#acc6d8511211e23ff33647d261f6f8b59">STD_MOVE</a>(<a class="code" href="class_c_time_tools.html#a86ff8e1d027ce0f6bc7611c430672f73">CTimeTools::GetTimeStr</a>(0, 0))).c_str(), <a class="code" href="namespace_share_api.html#a5f2e8e67d4a3a8d061bd8f109762a48d">ShareApi::GetCurrentProcessId</a>(), <a class="code" href="namespace_share_api.html#aa247d107f7e439e2c6871dfba195a022">ShareApi::GetCurrentThreadId</a>()));</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160; </div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">_file</a>.<a class="code" href="class_c_file.html#a50e268d58e7d90f6ba8448ea8e154211">IsOpen</a>()) <a class="code" href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">_file</a>.<a class="code" href="class_c_file.html#a8e3b6d9b96dfcd5e2205bc5a7ee85476">Close</a>();</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160; </div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    <span class="comment">// 创建新文件</span></div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">_file</a>.<a class="code" href="class_c_file.html#abb45c1c269a23f09ac84a33ddf988647">Open</a>(<a class="code" href="class_c_safe_logs.html#a08dde93476a99eabe315b0c618f05ecc">_strFileName</a>.GetReference().c_str(), <a class="code" href="class_c_file.html#a1e8db2a76f911a0840cc10a426fece01a6e7d3f31b0629460604ee6b89302a5c0">CFile::Share</a> | <a class="code" href="class_c_file.html#a1e8db2a76f911a0840cc10a426fece01ae96aac9b7964f75282cbab4a5be72e98">CFile::CreatePlus</a> | <a class="code" href="class_c_file.html#a1e8db2a76f911a0840cc10a426fece01a1d3ba989c1b1bfa67501a7941971b6ce">CFile::ReadWrite</a>)) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160; </div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_c_safe_logs_html_a08dde93476a99eabe315b0c618f05ecc"><div class="ttname"><a href="class_c_safe_logs.html#a08dde93476a99eabe315b0c618f05ecc">CSafeLogs::_strFileName</a></div><div class="ttdeci">StringImp&lt; tstring &gt; _strFileName</div><div class="ttdoc">当前的文件名称</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00078">SafeLog.h:78</a></div></div>
<div class="ttc" id="aclass_c_file_html_a50e268d58e7d90f6ba8448ea8e154211"><div class="ttname"><a href="class_c_file.html#a50e268d58e7d90f6ba8448ea8e154211">CFile::IsOpen</a></div><div class="ttdeci">bool IsOpen() const</div><div class="ttdoc">判断文件是否打开</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00042">File.cpp:42</a></div></div>
<div class="ttc" id="alogdef_8h_html_aca1fd1d8935433e6ba2e3918214e07f9"><div class="ttname"><a href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9">LogLevel</a></div><div class="ttdeci">LogLevel</div><div class="ttdef"><b>Definition:</b> <a href="logdef_8h_source.html#l00010">logdef.h:10</a></div></div>
<div class="ttc" id="a_string_tools_8cpp_html_accff640a08f04f7443e0da4eb25a4cf0"><div class="ttname"><a href="_string_tools_8cpp.html#accff640a08f04f7443e0da4eb25a4cf0">format_s</a></div><div class="ttdeci">std::string LIBTOOLS format_s(size_t bufSize, const char *mat,...)</div><div class="ttdef"><b>Definition:</b> <a href="_string_tools_8cpp_source.html#l00147">StringTools.cpp:147</a></div></div>
<div class="ttc" id="atools_8h_html_a65c91f8d7af3c67b8a21e089fdddd0fe"><div class="ttname"><a href="tools_8h.html#a65c91f8d7af3c67b8a21e089fdddd0fe">TCHAR</a></div><div class="ttdeci">#define TCHAR</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00187">tools.h:187</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_abed76fa949bfb689a91dd7f86eb68634"><div class="ttname"><a href="class_c_safe_logs.html#abed76fa949bfb689a91dd7f86eb68634">CSafeLogs::_fileMutex</a></div><div class="ttdeci">CMutex _fileMutex</div><div class="ttdoc">文件锁</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00073">SafeLog.h:73</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a4b0aebbbd5501c2d7924fcf90f169e9c"><div class="ttname"><a href="class_c_safe_logs.html#a4b0aebbbd5501c2d7924fcf90f169e9c">CSafeLogs::_nLogLevel</a></div><div class="ttdeci">int _nLogLevel</div><div class="ttdoc">当前日志级别</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00080">SafeLog.h:80</a></div></div>
<div class="ttc" id="atools_8h_html_a5fc7b9645f751ccc053f6f59ab0d8924"><div class="ttname"><a href="tools_8h.html#a5fc7b9645f751ccc053f6f59ab0d8924">TEXT</a></div><div class="ttdeci">#define TEXT(str)</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00195">tools.h:195</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a64b9b0012769472f36a4f89c5bf141ef"><div class="ttname"><a href="class_c_safe_logs.html#a64b9b0012769472f36a4f89c5bf141ef">CSafeLogs::~CSafeLogs</a></div><div class="ttdeci">~CSafeLogs()</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00038">SafeLog.cpp:38</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a8eb7b4e7971918a139c09db5a7926767"><div class="ttname"><a href="class_c_safe_logs.html#a8eb7b4e7971918a139c09db5a7926767">CSafeLogs::CSafeLogs</a></div><div class="ttdeci">CSafeLogs()</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00013">SafeLog.cpp:13</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a41d1dba7d735f5340dca726f889f5090"><div class="ttname"><a href="class_c_safe_logs.html#a41d1dba7d735f5340dca726f889f5090">CSafeLogs::SetLogLevel</a></div><div class="ttdeci">void SetLogLevel(LogLevel nLogLevel)</div><div class="ttdoc">设置日志级别</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00053">SafeLog.cpp:53</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a7ecaa2fd3c7a077e8f5f625e07de1fee"><div class="ttname"><a href="class_c_safe_logs.html#a7ecaa2fd3c7a077e8f5f625e07de1fee">CSafeLogs::FlushLog</a></div><div class="ttdeci">bool FlushLog()</div><div class="ttdoc">刷新日志，将缓存中的数据直接写入文件中</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00087">SafeLog.cpp:87</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a5f2e8e67d4a3a8d061bd8f109762a48d"><div class="ttname"><a href="namespace_share_api.html#a5f2e8e67d4a3a8d061bd8f109762a48d">ShareApi::GetCurrentProcessId</a></div><div class="ttdeci">LIBTOOLS ULONG GetCurrentProcessId()</div><div class="ttdoc">获取当前进程的ID</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l01172">ShareApi.cpp:1172</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a94a6c995167ac24ca71660e48fd0ce32"><div class="ttname"><a href="class_c_safe_logs.html#a94a6c995167ac24ca71660e48fd0ce32">CSafeLogs::SetSwitchFile</a></div><div class="ttdeci">void SetSwitchFile(UINT nfTime)</div><div class="ttdoc">设置切换日志文件时间(单位秒)</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00071">SafeLog.cpp:71</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a2a129a4fcd8c51a5c6830098943cf7bb"><div class="ttname"><a href="class_c_safe_logs.html#a2a129a4fcd8c51a5c6830098943cf7bb">CSafeLogs::SetWriteConsole</a></div><div class="ttdeci">void SetWriteConsole(bool isWriteConsole)</div><div class="ttdoc">设置是否输出到控制台</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00059">SafeLog.cpp:59</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a5b6ad5c65a41d59cd6c40a87ca173d93"><div class="ttname"><a href="class_c_safe_logs.html#a5b6ad5c65a41d59cd6c40a87ca173d93">CSafeLogs::_file</a></div><div class="ttdeci">CFile _file</div><div class="ttdoc">文件类</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00072">SafeLog.h:72</a></div></div>
<div class="ttc" id="a_safe_log_8h_html_af5f39b12ec7524d513a48e9b662a445a"><div class="ttname"><a href="_safe_log_8h.html#af5f39b12ec7524d513a48e9b662a445a">DEFAULT_LOG_SIZE</a></div><div class="ttdeci">#define DEFAULT_LOG_SIZE</div><div class="ttdoc">默认的日志大小10M</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00012">SafeLog.h:12</a></div></div>
<div class="ttc" id="aclass_c_lock_gurad_html"><div class="ttname"><a href="class_c_lock_gurad.html">CLockGurad</a></div><div class="ttdoc">常规锁包装器</div><div class="ttdef"><b>Definition:</b> <a href="_mutex_8h_source.html#l00041">Mutex.h:41</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a792e2fc28b9c58bf53c98163e055a5dd"><div class="ttname"><a href="class_c_safe_logs.html#a792e2fc28b9c58bf53c98163e055a5dd">CSafeLogs::_isWriteConsole</a></div><div class="ttdeci">bool _isWriteConsole</div><div class="ttdoc">是否写入控制台</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00081">SafeLog.h:81</a></div></div>
<div class="ttc" id="alogdef_8h_html_adc056e8970ce3dbab05a500d9f2b17f8"><div class="ttname"><a href="logdef_8h.html#adc056e8970ce3dbab05a500d9f2b17f8">GetLogLevelStr</a></div><div class="ttdeci">const TCHAR * GetLogLevelStr(LogLevel iLevel)</div><div class="ttdoc">返回日志等级对应的字符串</div><div class="ttdef"><b>Definition:</b> <a href="logdef_8h_source.html#l00019">logdef.h:19</a></div></div>
<div class="ttc" id="aclass_c_file_html_a0e1ef74f4c6c2e04b9577d208c2499e9"><div class="ttname"><a href="class_c_file.html#a0e1ef74f4c6c2e04b9577d208c2499e9">CFile::GetFileLength</a></div><div class="ttdeci">fsize_t GetFileLength() const</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00120">File.cpp:120</a></div></div>
<div class="ttc" id="aclass_c_time_tools_html_ab9cac1735bbfdc48f8c70c3acb7bd4ba"><div class="ttname"><a href="class_c_time_tools.html#ab9cac1735bbfdc48f8c70c3acb7bd4ba">CTimeTools::GetDateValue</a></div><div class="ttdeci">static long GetDateValue(time_t *t)</div><div class="ttdoc">从当前或者传入的时间值中获取当前日期值</div><div class="ttdef"><b>Definition:</b> <a href="_time_8cpp_source.html#l00110">Time.cpp:110</a></div></div>
<div class="ttc" id="anamespace_share_api_html_aa247d107f7e439e2c6871dfba195a022"><div class="ttname"><a href="namespace_share_api.html#aa247d107f7e439e2c6871dfba195a022">ShareApi::GetCurrentThreadId</a></div><div class="ttdeci">LIBTOOLS ULONG GetCurrentThreadId()</div><div class="ttdoc">获取当前线程ID</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l01163">ShareApi.cpp:1163</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_aeb6f84401d06477a6dc85cb44f029fc7"><div class="ttname"><a href="class_c_safe_logs.html#aeb6f84401d06477a6dc85cb44f029fc7">CSafeLogs::SwitchLogFile</a></div><div class="ttdeci">bool SwitchLogFile()</div><div class="ttdoc">切换日志文件</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00146">SafeLog.cpp:146</a></div></div>
<div class="ttc" id="alogdef_8h_html_aca1fd1d8935433e6ba2e3918214e07f9abb2c17c44c343a8367060db4175f39ea"><div class="ttname"><a href="logdef_8h.html#aca1fd1d8935433e6ba2e3918214e07f9abb2c17c44c343a8367060db4175f39ea">LOG_NORMAL</a></div><div class="ttdef"><b>Definition:</b> <a href="logdef_8h_source.html#l00013">logdef.h:13</a></div></div>
<div class="ttc" id="a_safe_log_8h_html_acf3ddfcd82496629d7ab869a57f2fedd"><div class="ttname"><a href="_safe_log_8h.html#acf3ddfcd82496629d7ab869a57f2fedd">DEFAULT_FLUSH_TIME</a></div><div class="ttdeci">#define DEFAULT_FLUSH_TIME</div><div class="ttdoc">默认每隔多长时间切换一次日志</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00013">SafeLog.h:13</a></div></div>
<div class="ttc" id="aclass_c_file_html_a1e8db2a76f911a0840cc10a426fece01a1d3ba989c1b1bfa67501a7941971b6ce"><div class="ttname"><a href="class_c_file.html#a1e8db2a76f911a0840cc10a426fece01a1d3ba989c1b1bfa67501a7941971b6ce">CFile::ReadWrite</a></div><div class="ttdoc">读写</div><div class="ttdef"><b>Definition:</b> <a href="_file_8h_source.html#l00048">File.h:48</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a79ac12b58225066b1533f190a579e64b"><div class="ttname"><a href="class_c_safe_logs.html#a79ac12b58225066b1533f190a579e64b">CSafeLogs::SetLogFileSize</a></div><div class="ttdeci">void SetLogFileSize(UINT64 nFileMaxSize)</div><div class="ttdoc">设置默认日志文件大小，单位（Byte）</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00065">SafeLog.cpp:65</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a972c8fa984c8698181dcefbb2ac492fb"><div class="ttname"><a href="class_c_safe_logs.html#a972c8fa984c8698181dcefbb2ac492fb">CSafeLogs::SetLogPath</a></div><div class="ttdeci">void SetLogPath(const TCHAR *szLogPath)</div><div class="ttdoc">设置日志路径</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00043">SafeLog.cpp:43</a></div></div>
<div class="ttc" id="aclass_c_time_tools_html_ade52c34673cca32faab3ac984e1b40c5"><div class="ttname"><a href="class_c_time_tools.html#ade52c34673cca32faab3ac984e1b40c5">CTimeTools::GetDateStr</a></div><div class="ttdeci">static std::string GetDateStr(int chDate='-')</div><div class="ttdoc">获取当前日期字符串(年月日时分秒毫秒)</div><div class="ttdef"><b>Definition:</b> <a href="_time_8cpp_source.html#l00049">Time.cpp:49</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_aef956466255d247b0353aa78b683cd68"><div class="ttname"><a href="class_c_safe_logs.html#aef956466255d247b0353aa78b683cd68">CSafeLogs::_tLastWrite</a></div><div class="ttdeci">time_t _tLastWrite</div><div class="ttdoc">上一次写入的时间</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00076">SafeLog.h:76</a></div></div>
<div class="ttc" id="a_file_tools_8cpp_html_ac466c2c83e8a6b7daf322c2ad4590e0f"><div class="ttname"><a href="_file_tools_8cpp.html#ac466c2c83e8a6b7daf322c2ad4590e0f">CreateMultiDir</a></div><div class="ttdeci">LIBTOOLS bool CreateMultiDir(const TCHAR *szPath)</div><div class="ttdoc">创建多级目录</div><div class="ttdef"><b>Definition:</b> <a href="_file_tools_8cpp_source.html#l00050">FileTools.cpp:50</a></div></div>
<div class="ttc" id="atools_8h_html_ae44d8d5d0e473c82cf8f2021a86cb6a4"><div class="ttname"><a href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a></div><div class="ttdeci">INTPTR_T fsize_t</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00237">tools.h:237</a></div></div>
<div class="ttc" id="aclass_c_file_html_a1e8db2a76f911a0840cc10a426fece01ae96aac9b7964f75282cbab4a5be72e98"><div class="ttname"><a href="class_c_file.html#a1e8db2a76f911a0840cc10a426fece01ae96aac9b7964f75282cbab4a5be72e98">CFile::CreatePlus</a></div><div class="ttdoc">如果文件不存在则创建此文件，存在则打开它</div><div class="ttdef"><b>Definition:</b> <a href="_file_8h_source.html#l00053">File.h:53</a></div></div>
<div class="ttc" id="a_string_tools_8h_html_a0a60694576e1be5888918efa92f551d2"><div class="ttname"><a href="_string_tools_8h.html#a0a60694576e1be5888918efa92f551d2">TO_TSTRING</a></div><div class="ttdeci">#define TO_TSTRING(str)</div><div class="ttdef"><b>Definition:</b> <a href="_string_tools_8h_source.html#l00079">StringTools.h:79</a></div></div>
<div class="ttc" id="aclass_c_file_html_a68f6596c56190afd38fbe236ade81266"><div class="ttname"><a href="class_c_file.html#a68f6596c56190afd38fbe236ade81266">CFile::Write</a></div><div class="ttdeci">virtual fsize_t Write(const void *buf, fsize_t size)</div><div class="ttdoc">写入数据到文件中</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00064">File.cpp:64</a></div></div>
<div class="ttc" id="atools_8h_html_a57be03562867144161c1bfee95ca8f7c"><div class="ttname"><a href="tools_8h.html#a57be03562867144161c1bfee95ca8f7c">UINT64</a></div><div class="ttdeci">unsigned long long UINT64</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00130">tools.h:130</a></div></div>
<div class="ttc" id="aclass_c_file_html_a1e8db2a76f911a0840cc10a426fece01a6e7d3f31b0629460604ee6b89302a5c0"><div class="ttname"><a href="class_c_file.html#a1e8db2a76f911a0840cc10a426fece01a6e7d3f31b0629460604ee6b89302a5c0">CFile::Share</a></div><div class="ttdoc">共享</div><div class="ttdef"><b>Definition:</b> <a href="_file_8h_source.html#l00049">File.h:49</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a7269da8c406a066045bbda712700c568"><div class="ttname"><a href="class_c_safe_logs.html#a7269da8c406a066045bbda712700c568">CSafeLogs::_WriteLog</a></div><div class="ttdeci">fsize_t _WriteLog(const char *szLog, fsize_t size, LogLevel nLogLevel, bool bHead, bool bFlush)</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00110">SafeLog.cpp:110</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_acfec8eab5ce3695c7f3c111bc42b9ddf"><div class="ttname"><a href="class_c_safe_logs.html#acfec8eab5ce3695c7f3c111bc42b9ddf">CSafeLogs::_nFileMaxSize</a></div><div class="ttdeci">UINT64 _nFileMaxSize</div><div class="ttdoc">单个文件大小</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00074">SafeLog.h:74</a></div></div>
<div class="ttc" id="atools_8h_html_a36cb3b01d81ffd844bbbfb54003e06ec"><div class="ttname"><a href="tools_8h.html#a36cb3b01d81ffd844bbbfb54003e06ec">UINT</a></div><div class="ttdeci">unsigned int UINT</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00139">tools.h:139</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a3dd941c690e7a627b27eca4c62f7d91a"><div class="ttname"><a href="class_c_safe_logs.html#a3dd941c690e7a627b27eca4c62f7d91a">CSafeLogs::_nFlushTime</a></div><div class="ttdeci">UINT _nFlushTime</div><div class="ttdoc">每隔多长时间刷新一次日志</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00075">SafeLog.h:75</a></div></div>
<div class="ttc" id="a_string_tools_8cpp_html_a68e59768ff7f1f1fe4dca5ccaa26de28"><div class="ttname"><a href="_string_tools_8cpp.html#a68e59768ff7f1f1fe4dca5ccaa26de28">format</a></div><div class="ttdeci">std::string format(const char *mat,...)</div><div class="ttdef"><b>Definition:</b> <a href="_string_tools_8cpp_source.html#l00127">StringTools.cpp:127</a></div></div>
<div class="ttc" id="atools_8h_html_ab689500aaec0db066e3ac9483d3fe425"><div class="ttname"><a href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a></div><div class="ttdeci">#define NullPtr</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00119">tools.h:119</a></div></div>
<div class="ttc" id="anamespace_share_api_html_af5477174100c9b0c5fa9b8a1787c09af"><div class="ttname"><a href="namespace_share_api.html#af5477174100c9b0c5fa9b8a1787c09af">ShareApi::FilePathExists</a></div><div class="ttdeci">LIBTOOLS BOOL FilePathExists(const TCHAR *szFileName)</div><div class="ttdoc">检查文件是否存在</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00474">ShareApi.cpp:474</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a56df89a4b10c88b3f510ce1353e3ff76"><div class="ttname"><a href="class_c_safe_logs.html#a56df89a4b10c88b3f510ce1353e3ff76">CSafeLogs::_strCurPath</a></div><div class="ttdeci">StringImp&lt; tstring &gt; _strCurPath</div><div class="ttdoc">当前文件路径</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00079">SafeLog.h:79</a></div></div>
<div class="ttc" id="aclass_c_time_tools_html_a86ff8e1d027ce0f6bc7611c430672f73"><div class="ttname"><a href="class_c_time_tools.html#a86ff8e1d027ce0f6bc7611c430672f73">CTimeTools::GetTimeStr</a></div><div class="ttdeci">static std::string GetTimeStr(int chTime=':', int chMill='.')</div><div class="ttdoc">获取当前时间字符串(年月日时分秒毫秒)</div><div class="ttdef"><b>Definition:</b> <a href="_time_8cpp_source.html#l00072">Time.cpp:72</a></div></div>
<div class="ttc" id="aclass_c_file_html_abb45c1c269a23f09ac84a33ddf988647"><div class="ttname"><a href="class_c_file.html#abb45c1c269a23f09ac84a33ddf988647">CFile::Open</a></div><div class="ttdeci">virtual bool Open(const TCHAR *sPath, unsigned int mode)</div><div class="ttdoc">打开文件</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00047">File.cpp:47</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a67a16f7ebc22906bf159e3a8f88c5124"><div class="ttname"><a href="class_c_safe_logs.html#a67a16f7ebc22906bf159e3a8f88c5124">CSafeLogs::WriteLog</a></div><div class="ttdeci">fsize_t WriteLog(const char *szLog, fsize_t size, LogLevel nLogLevel)</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00082">SafeLog.cpp:82</a></div></div>
<div class="ttc" id="a_safe_log_8cpp_html_a660395cdc8ba7aca573aed6c676faae8"><div class="ttname"><a href="_safe_log_8cpp.html#a660395cdc8ba7aca573aed6c676faae8">USE_LIBTOOLS</a></div><div class="ttdeci">USE_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00009">SafeLog.cpp:9</a></div></div>
<div class="ttc" id="atools_8h_html_acc6d8511211e23ff33647d261f6f8b59"><div class="ttname"><a href="tools_8h.html#acc6d8511211e23ff33647d261f6f8b59">STD_MOVE</a></div><div class="ttdeci">#define STD_MOVE(object)</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00043">tools.h:43</a></div></div>
<div class="ttc" id="a_safe_log_8h_html"><div class="ttname"><a href="_safe_log_8h.html">SafeLog.h</a></div></div>
<div class="ttc" id="aclass_c_file_html_a8e3b6d9b96dfcd5e2205bc5a7ee85476"><div class="ttname"><a href="class_c_file.html#a8e3b6d9b96dfcd5e2205bc5a7ee85476">CFile::Close</a></div><div class="ttdeci">virtual void Close()</div><div class="ttdoc">关闭文件</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00127">File.cpp:127</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a353b09fdf1a3a8f57d41c0cd94825765"><div class="ttname"><a href="class_c_safe_logs.html#a353b09fdf1a3a8f57d41c0cd94825765">CSafeLogs::WriteLogHead</a></div><div class="ttdeci">fsize_t WriteLogHead(LogLevel nLogLevel)</div><div class="ttdoc">写入日志头</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8cpp_source.html#l00094">SafeLog.cpp:94</a></div></div>
<div class="ttc" id="aclass_c_safe_logs_html_a50d55056cc11242a56bdab1aeb5e43ff"><div class="ttname"><a href="class_c_safe_logs.html#a50d55056cc11242a56bdab1aeb5e43ff">CSafeLogs::_strLogPath</a></div><div class="ttdeci">StringImp&lt; tstring &gt; _strLogPath</div><div class="ttdoc">当前的文件路径</div><div class="ttdef"><b>Definition:</b> <a href="_safe_log_8h_source.html#l00077">SafeLog.h:77</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
